﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace tu_xls_2
{
    class Program
    {
        static void Main(string[] args)
        {
            Excel.Application xlsApp = new Excel.ApplicationClass();
            Excel.Workbook xlsWorkBook;
            Excel.Worksheet xlsWorkSheet;
            object misValue = System.Reflection.Missing.Value;


            string xls_path = "c:\\paid_unpaid.xls";
            //open specific xls file
            xlsWorkBook = xlsApp.Workbooks.Open(
                    xls_path,
                    misValue,
                    true,
                    misValue, //object format
                    "",
                    "",
                    true,
                    Microsoft.Office.Interop.Excel.XlPlatform.xlWindows,
                    "\t",
                    false,
                    false,
                    misValue,
                    true,
                    1,
                    0
                );
            xlsWorkSheet = (Excel.Worksheet)xlsWorkBook.Worksheets.get_Item(1);
            Excel.Range allValidRange = xlsWorkSheet.UsedRange;

            //get some information about the range
            Console.WriteLine("Row x Column = " + allValidRange.Rows.Count + " x " + allValidRange.Columns.Count);

            xlsWorkBook.Close(true, xls_path, misValue);
            xlsApp.Quit();
            Console.ReadLine();

        }
    }
}
